package{
	import flash.events.MouseEvent;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.external.ExternalInterface;
	
	[SWF(frameRate="60",width="640",height="480")]
	public class Main extends Sprite {
		
		public function Main(){
			stage.scaleMode=StageScaleMode.NO_SCALE;
			stage.align=StageAlign.TOP_LEFT;
			graphics.beginFill(0xeeeedd);
			graphics.drawRect(0,0,640,480);
			graphics.endFill();
			
			var data:Array=new Array(26);
			var list:Array=new Array(10);
			for(var i:int=0,n:int=data.length;i<n;i++){
				data[i]=list.join(String.fromCharCode(97+i));
				list.length+=i<13?1:-1;
			}
			
			var window:Sprite=new Sprite();
			var sprite:Sprite=new Sprite();
			sprite.addChild(UI.createTextInput(100,"测试TextInput"));
			sprite.addChild(UI.createTextArea(120,80,"测试TextArea"));
			sprite.addChild(UI.createLabel("测试Label",null,100));
			sprite.addChild(UI.createButton("测试Button",null,null,120,40));
			sprite.addChild(UI.createCheckBox("测试CheckBox1",null,false,"L"));
			sprite.addChild(UI.createCheckBox("测试CheckBox2",null,true,"L"));
			sprite.addChild(UI.createRadioGroup(["测试Radio1","测试Radio2","测试Radio3"]));
			sprite.addChild(UI.createComboBox(data,null,3));
			window.addChild(sprite);
			window.addChild(UI.createList(data,null,0,200,3));
			window.addChild(UI.createTree([["测试Tree",data[0]],[data[1],[data[2],data[3]],data[4]],data],null,0,200));
			window.x=window.y=30;
			addChild(window);
			
			UI.layout(sprite,"L",250);
			UI.layout(window,"L",0);
			
			addEventListener(MouseEvent.ROLL_OVER,onMouseOver);
			addEventListener(MouseEvent.ROLL_OUT,onMouseOut);
		}
		
		private function onMouseOver(event:MouseEvent):void{
			if(ExternalInterface.available){
				ExternalInterface.call("eval","var _onFlashMousewheel=function(e){e=e||event;e.preventDefault&&e.preventDefault();e.stopPropagation&&e.stopPropagation();return e.returnValue=false;};if(navigator.userAgent.indexOf(\"Firefox\")!=-1){document.addEventListener('DOMMouseScroll',_onFlashMousewheel,false);}else{window.onmousewheel=document.onmousewheel=_onFlashMousewheel;}");
			}
		}
		
		private function onMouseOut(event:Event):void{
			if(ExternalInterface.available){
				ExternalInterface.call("eval","if(navigator.userAgent.indexOf(\"Firefox\")!=-1){document.removeEventListener('DOMMouseScroll', _onFlashMousewheel,false);}else{window.onmousewheel=document.onmousewheel=null;}");
			}
		}
	}
}